#include "leds.h"
#include <wiringPi.h>

int leds[4] = {25, 26, 27, 28};

/*
 *  init led device, set to be OUTPUT.
 */
void led_init()
{
    int i;
    for (i = 0; i < sizeof(leds); ++i){
        pinMode(leds[i], OUTPUT);
    }
}

/*
 *  light one led.
 */
void light_led(int number)
{
    digitalWrite(leds[number], 1);
}

/*
 *  close one led.
 */
void close_led(int number)
{
    digitalWrite(leds[number], 0);
}

/*
 * close all leds.
 */
void close_all_leds()
{
    int i;
    for (i = 0; i < sizeof(leds); ++i){
        digitalWrite(leds[i], 0);
    }
}

/*
 * light all leds.
 */
void light_all_leds()
{
    int i ;
    for (i = 0; i < sizeof(leds); ++i){
        digitalWrite(leds[i], 1);
    }
}

/*
 * just light one led, and close other leds.
 */
void light_one_led(int number)
{
    int i ;
    for (i = 0; i < sizeof(leds); ++i){
        if (number == i)
            digitalWrite(leds[i], 1);
        else
            digitalWrite(leds[i], 0);
    }
}

/*
 * just close one leds, and light other leds.
 */
void close_one_led(int number)
{
    int i ;
    for (i = 0; i < sizeof(leds); ++i){
        if (number == i)
            digitalWrite(leds[i], 0);
        else
            digitalWrite(leds[i], 1);
    }
}
